Skip to content
This repository was archived by the owner on Mar 5, 2022. It is now read-only.

Conversation

@bahmutov
Copy link
Contributor

/// <reference types="cypress" />
import 'cypress-react-selector'

it(..., () => {
  mount(<ProductsList />)
  cy.contains('First item').should('be.visible')
  cy.get('.product').should('have.length', 2)

  // use https://github.com/abhinaba-ghosh/cypress-react-selector
  // to find DOM elements by React component constructor name or state
  cy.waitForReact(1000, '#cypress-root')
  cy.react('ProductsContainer').should('have.class', 'product-container')
  cy.react('AProduct').should('have.length', 2)
  cy.react('AProduct', { name: 'Second item' })
    .should('be.visible')
    .and('have.text', 'Second item')
})

Screen Shot 2020-05-11 at 5 24 56 PM

@bahmutov bahmutov merged commit 856864a into master May 11, 2020
@bahmutov bahmutov deleted the try-react-plugin branch May 11, 2020 22:30
@bahmutov
Copy link
Contributor Author

🎉 This PR is included in version 4.2.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Try using cypress-react-selector with component test

2 participants